<!--{include /service/service_head}-->


<!-- End #sidebar -->
	<div id="main-content">
		<!-- Main Content Section with everything -->

		<!-- Page Head -->
		<!-- End .clear -->
		
		<div class="content-box">
			<!-- Start Content Box -->
			<div class="content-box-header">
				<h3>設備管理</h3>
				<ul class="content-box-tabs" style="display:none;">

					<li><a href="#tab1" class="default-tab">详细</a></li>
					<!-- href must be unique and match the id of target div -->
					<li><a href="#tab2">编辑</a></li>
				</ul>
				<div class="clear"></div>
			</div>
			<!-- End .content-box-header -->
			
			<div class="content-box-content">
				<form action="/service/deviceManageEdit.php" id="indexform" method="post">
				<div class="tab-content default-tab" id="tab1">
					<!-- This is the target div. id must match the href of this div's tab -->
					<div class="table_box">
						<table>
						<tbody id="person_info">
							<tr>
								<td class="text_left"> 設備名：</td>
								<td>
									<input type="hidden" value="{$device['id']}" name="device_id" />
									<input type="text" value="{$device['device_name']}" name="device_name" />
								</td>
							</tr>
							
							<!--{if $device['id'] > 0}-->
							<tr>
								<td class="text_left">設備利用コース名：</td>
								<td>
									<table>
										<tbody id="addDelete">
										<!--{loop DeviceUse::GetServicesById($device['id']) $index1 $one1}-->
										<tr>
											<td>{$one1['service_name']}(level:{$one1['skill_level']})</td>
											<td><a class="close_btn" deviceId="{$device['id']}" serviceId="{$one1['id']}"></a></td>
										</tr>
										<!--{/loop}-->
										</tbody>
									</table>
								</td>
							</tr>
							<tr>
								<td class="text_left">利用コース登録：</td>
								<td>
									<p>
										<select name="service_id" class="small-input">
										<option value="0">選択してください</option>
										${Utility::Option(Utility::OptionArray($serviceList, 'id', 'service_name'), 0)}
									</select>
									</p>
									<p>level:<select name="skill_level" class="small-input">
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
									</select>
										<input type="button" value="登録" id="addService" class="button"/>
									</p>
								</td>
							</tr>
							<!--{/if}-->
							
							<tr>
								<td class="text_left">設備在庫数：</td>
								<td><input type="text" value="{$device['device_count']}" name="device_count" /></td>
							</tr>
							<tr>

								<td class="text_left">所属店舗：</td>
								<td>
									<select name="shop_id" class="small-input">
										<option value="0">選択してください</option>
										${Utility::Option(Utility::OptionArray($shopList, 'id', 'shop_name'), $device['shop_id'])}
									</select>
								</td>
							</tr>
							
						</tbody>
						</table>
					</div>
					<p class="bottom_m"><input type="submit" class="button" value="登録" /></p>
					<p class="bottom_m"><a href="{$_SERVER['HTTP_REFERER']}">戻る</a></p>
					<div style="display:none">
						<table>
							<tr>
								<td colspan="7">
									<div class="pagination"> 
										<a href="#" title="First Page">&laquo; First</a>
										<a href="#" title="Previous Page">&laquo; Previous</a> 
										<a href="#" class="number" title="1">1</a> 
										<a href="#" class="number" title="2">2</a> 
										<a href="#" class="number current" title="3">3</a>
										 <a href="#" class="number" title="4">4</a> 
										 <a href="#" title="Next Page">Next &raquo;</a>
										 <a href="#" title="Last Page">Last &raquo;</a> </div>
									<!-- End .pagination -->
									<div class="clear"></div>
								</td>
							</tr>
						</table>
					</div>
				</div>
				</form>
			</div>
			<!-- End .content-box-content -->
		</div>

		<!-- End .content-box -->
		<!-- End .content-box -->
		<!-- End .content-box -->
		<div class="clear"></div>
		<!-- Start Notifications -->
		<!-- End Notifications -->
		<div id="footer"> <small>
			<!-- Remove this notice or replace it with whatever you want -->

			&#169; Copyright 2011 川崎エステ　エレガントリゾート　すべての女性を美しく幸せに | Powered by <a href="#">ZHONGHUA</a> | <a href="#">Top</a> </small> </div>
		<!-- End #footer -->
	</div>
	<!-- End #main-content -->
</div>

</body>
<!-- Download From www.exet.tk-->
</html>


<script type="text/javascript"> 
jQuery(function(){
	$("a[class='close_btn']").bind('click', function(){
		var data = "action=del&serviceId=" + $(this).attr("serviceId") + "&deviceId=" + $(this).attr('deviceId');
		
		var This = this;
		$.get("{$webRoot}/service/deviceSkillEdit.php", data, function(data){
			if( data['error'] == 0 ){
				$(This).unbind('click');
				$(This).parent().parent().remove();
			}
			
		}, "json");
	});

	$("#addService").bind('click', function(){
		var deviceId = $("input[name='device_id']").val();
		var serviceId = $("select[name='service_id']").val();
		if( serviceId < 1 ){
			return ;
		}
		var data = "action=add&serviceId=" + serviceId + "&deviceId=" + deviceId;
		data = data + "&skillLevel=" + $("select[name='skill_level']").val();
		$.get("{$webRoot}/service/deviceSkillEdit.php", data, function(data){
			if( data['error'] == 0 ){
				$("#addDelete").append('<tr><td>' + data.data + '</td><td>' +  '<a class="close_btn" deviceId="' + deviceId + '" serviceId="' + serviceId + '"></a></td></tr>');
				$("a[class='delete']").last().bind('click', function(){
					var data = "action=del&serviceId=" + $(this).attr("serviceId") + "&deviceId=" + $(this).attr('deviceId');
					var This = this;
					$.get("{$webRoot}/service/deviceSkillEdit.php", data, function(data){
						if( data['error'] == 0 ){
							$(This).unbind('click');
							$(This).parent().parent().remove();
						}
						
					}, "json");
				})
			}
		}, "json");
	});

	$("select[name='shop_id']").bind("change", function(){
		if( $(this).val() < 1 ){
			return ;
		}
		$.get("{$webRoot}/ajax/GetServiceList.php", "shopId=" + $(this).val(), function(data){
			var options = '<option value="0">選択してください</option>';
			for(var index in data.data){
				if( !index ){
					continue;
				}
				options = options + '<option value="' + index + '">' + data.data[index].service_name + '</option>';
			}
			$("select[name='service_id']").html(options);
		}, "json");
		
	});
})
</script> 
</html> 